﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace MongoServices
{
	/// <summary>
	/// The base MongoServices model that every model must inherit.
	/// </summary>
	public abstract partial class MongoServicesModel
	{
		#region Public Properties
		/// <summary>
		/// A unique identifier for the model.
		/// </summary>
		public ObjectId Id { get; set; }

		/// <summary>
		/// The date the model was initially saved to the database.
		/// </summary>
		public DateTime DateCreated { get; internal set; }

		/// <summary>
		/// The date the model was last saved to the database.
		/// </summary>
		public DateTime DateModified { get; internal set; }

		/// <summary>
		/// Gets whether or not the model is marked for deletion.
		/// </summary>
		/// <value><c>true</c> indicates that this record is marked for deletion when the repository <c>Save</c> method is called</value>.
		[BsonIgnore]
		public bool MarkedForDelete { get; private set; }
		#endregion

		#region Public Methods
		/// <summary>
		/// Marks the model for deletion.
		/// </summary>
		/// <see cref="MongoServicesModel.MarkedForDelete"/>
		public void MarkForDelete()
		{
			MarkedForDelete = true;
		}

		/// <summary>
		/// Unmarks the model for deletion.
		/// </summary>
		/// <see cref="MongoServicesModel.MarkedForDelete"/>
		public void UnmarkForDelete()
		{
			MarkedForDelete = false;
		}
		#endregion
	}
}
